﻿using AiXiu.BLL;
using AiXiu.Common;
using AiXiu.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace AiXiu.WebSite
{
    public partial class Register : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnRegister_Click(object sender, EventArgs e)
        {
            // 判断是否通过表单验证
            if (Page.IsValid)
            {
                // 验证码校验Session["Captcha"]
                string code = txtVerification.Text;
                if (code != Session["vali"].ToString())
                {
                    this.Alert("codeerror", "输入的验证码有误");
                    return;
                }

                // 获取页面输入信息
                TBLogins login = new TBLogins();
                login.UserName = txtUserName.Text;
                login.MobileNumber = txtUserMoblie.Text;
                login.Password = txtPassword.Text;

                // 调用UserBLL中的注册方法
                // 注册成功，弹框并跳转this.AlertAndRedirect,注册失败，弹框提示
                LoginBLL loginBLL = new LoginBLL();
                OperResult result = loginBLL.Register(login);
                if (result.StatusCode == StatusCode.Succeed)
                {
                    this.AlertAndRedirect("regsuccess", "注册成功", "Login.aspx");
                }
                else
                {
                    this.Alert("regerror", result.Message);
                }
            }
        }
    }
}